package cn.itsource.aigou.client;

import cn.itsource.aigou.domain.ProductDoc;
import cn.itsource.aigou.util.AjaxResult;
import cn.itsource.aigou.util.PageList;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public class ProductESClientFallBackFacotry implements FallbackFactory<ProductESClient> {
    @Override
    public ProductESClient create(Throwable throwable) {
        return new ProductESClient() {
            @Override
            public AjaxResult save(ProductDoc productDoc) {
                return AjaxResult.me().setSuccess(false).setMessage("系统异常!");
            }

            @Override
            public AjaxResult save(List<ProductDoc> productDocs) {
                return AjaxResult.me().setSuccess(false).setMessage("系统异常!");
            }

            @Override
            public AjaxResult delete(Long productId) {
                return AjaxResult.me().setSuccess(false).setMessage("系统异常!");
            }

            @Override
            public AjaxResult delete(List<ProductDoc> productDocs) {
                return AjaxResult.me().setSuccess(false).setMessage("系统异常!");
            }

            @Override
            public PageList<ProductDoc> search(Map<String, Object> param) {
                return null;
            }
        };
    }
}
